import java.util.*;
import java.util.regex.Pattern;

class NeighbourNumbers {

    public static void main(String[] args) {
		
		//Init
        Scanner in = new Scanner(System.in);
        String input = "";
        Integer[] inputInt = new Integer[0];        
        String[] splittedInput = new String[0];

		//Read and verify input
        do {
            System.out.print("Enter number's sequence: ");

            input = in.nextLine();
            splittedInput = input.split("\\s+");
            inputInt = new Integer[splittedInput.length];
        }
        while (!verify(splittedInput));
        
		//Convert input to int
        for (int i = 0; i < splittedInput.length; i++) {
			inputInt[i] = Integer.parseInt(splittedInput[i]);
		}
        
        System.out.println("Entered array is: " + Arrays.toString(inputInt));

        int min = Integer.MAX_VALUE;
        int minIndex = 0;

        for (int i = 0; i < (inputInt.length-1); i++) {
            int tmpMin = Math.abs(inputInt[i] - inputInt[i+1]);
            if (tmpMin < min) {
                min = tmpMin;
                minIndex = i;
            }
        }
        System.out.println("Minimal difference is: " + min + "\nIndex is: " + minIndex);
    }
    
	//Verify whether input string contains only numbers
    public static boolean verify(String[] input) {
        for (int i = 0; i < input.length; i++) {
            if (!input[i].matches("\\d+")) {
                System.out.println("Input contains non-digit (\""+ input[i] +"\") element(s).\nPlease, revise.");
                return false;
            }
        }
        return true;
    }
}